<?php
$link=mysqli_connect('localhost','root','root','mydb','3306');
if(!$link){
    exit(mysqli_connect_errno());
}
if(!mysqli_set_charset($link,'utf8')){
    exit(mysqli_error($link));
}